home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_test / test_dictionary2.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  1.3 KB  |  69 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_DICTIONARY2
  5.  
  6. creation {ANY}
  7.    make
  8.    
  9. feature {ANY}
  10.    
  11.    k1: STRING is "k1";
  12.    k2: STRING is "k2";
  13.    k3: STRING is "k3";
  14.    k4: STRING is "k4";
  15.  
  16.    v1: STRING is "v1";
  17.    v2: STRING is "v2";
  18.    v3: STRING is "v3";
  19.    v4: STRING is "v4";
  20.  
  21.    make is
  22.       local
  23.      d: DICTIONARY[STRING,STRING];
  24.      k, v: STRING;
  25.      i: INTEGER;
  26.      v_list, k_list: ARRAY[STRING];
  27.       do
  28.          !!d.make;
  29.          d.put(v1,k1);
  30.          d.put(v2,k2);
  31.          d.put(v3,k3);
  32.          d.put(v4,k4);
  33.      from  
  34.         v_list := <<v1,v2,v3,v4>>;
  35.         k_list := <<k1,k2,k3,k4>>;
  36.         i := 1;
  37.      invariant
  38.         v_list.count = k_list.count;
  39.      variant
  40.         v_list.count - 1
  41.      until
  42.         i > d.count     
  43.      loop
  44.         v := d.item(i);
  45.         k := d.key(i);
  46.         v_list.remove(v_list.fast_index_of(v));
  47.         k_list.remove(k_list.fast_index_of(k));
  48.         i := i + 1
  49.      end;
  50.      is_true(v_list.empty);
  51.      is_true(k_list.empty);
  52.       end;
  53.    
  54.    is_true(b: BOOLEAN) is
  55.       do
  56.      cpt := cpt + 1;
  57.      if not b then
  58.         std_output.put_string("TEST_DICTIONARY2: ERROR Test # ");
  59.         std_output.put_integer(cpt);
  60.         std_output.put_string("%N");
  61.      else
  62. --        std_output.put_string("Yes%N");
  63.      end;
  64.       end;
  65.    
  66.    cpt: INTEGER;
  67.    
  68. end -- TEST_DICTIONARY2
  69.